package cn.udrm.water.base.v1.administration.entities;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import org.hibernate.annotations.GenericGenerator;

/**
 * 行政单位
 * @author liukang
 * @date 2018年11月18日
 */
@Getter
@Setter
@NoArgsConstructor
@Entity(name="AdministrationUnit")
@Table(name="M_ADMINISTRATION_UNIT")
@NamedEntityGraphs({
	@NamedEntityGraph(name="AdministrationUnit.all",
			attributeNodes={
			@NamedAttributeNode("childrens")
	})
})
public class AdministrationUnit {

	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid")
	@GeneratedValue(generator="idGenerator")
	@Column(name="ID")
	private String id;
	private String entityCode;
	private Date createDate;
	private String personGuid;
	private String personName;
	
	private String name;
	
	@Column(name="INFO_REMARKS", length=2048)
	private String infoRemarks;
	
	@ManyToOne(optional=true)
	@JoinColumn(name="PARENT_ID")
	private AdministrationUnit parent;
	@OneToMany(mappedBy="parent")
	private List<AdministrationUnit> childrens;
	
	public AdministrationUnit(String id) {
		this.id = id;
	}
}
